import 'package:shared_preferences/shared_preferences.dart';

class SharedPreferencesHelper{

  static int id;
  static String account;
  static String password;

  static SharedPreferences preferences;

  static Future<bool> getInstance() async {
    preferences = await SharedPreferences.getInstance();
    return true;
  }

  static void SetLastInfo(String number,String pass)async{
    SharedPreferences preferences = await SharedPreferences.getInstance();
    preferences.setString("NUMBER", number);
    preferences.setString("PASS", pass);
  }

  static Future<Map> GetLastInfo()async{
    SharedPreferences preferences = await SharedPreferences.getInstance();
    Map map=Map();
    map['NUMBER']=preferences.getString("NUMBER");
    map['PASS']=preferences.getString("PASS");
    return map;
  }

  /// 存储字符串
  static save(String key, String value) async {
    SharedPreferences pres = preferences;
    preferences.setString(key, value);
    print('key: $key value: $value');
  }

  /// 取字符串
  static get(String key) async {
    SharedPreferences prefs = preferences;
    return prefs.getString(key);
  }
}